/*
 * @Author: xuhua
 * @Date: 2023-09-13 17:16:58
 * @LastEditors: xuhua
 * @LastEditTime: 2023-09-19 13:51:33
 * @FilePath: /v3-element-admin/src/api/menu/index.ts
 * @Description:
 */
import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { MenuQuery, MenuVO, MenuForm } from "./types";

export enum Api {
	LISTMENUS = "/menus/list",
	LISTMENUOPTIONS = "/logout",
	GETMENUFORM = "/logout1",
}

/**
 * 获取路由列表
 */
export const listRoutes = () => request.get(Api.LISTMENUS);

/**
 * 获取菜单树形列表
 *
 * @param queryParams
 */
export const listMenus = (queryParams: MenuQuery): AxiosPromise<MenuVO[]> =>
	request.get(Api.LISTMENUS, { params: queryParams });

/**
 * 获取菜单下拉树形列表
 */
export const listMenuOptions = (): AxiosPromise<OptionType[]> => request.get(Api.LISTMENUOPTIONS);

/**
 * 获取菜单表单数据
 *
 * @param id
 */
export const getMenuForm = (id: number): AxiosPromise<MenuForm> => request.get(Api.GETMENUFORM + "/" + id + "/form");

/**
 * 添加菜单
 *
 * @param data
 */
export const addMenu = (data: MenuForm) => request.post(Api.LISTMENUS, data);

/**
 * 修改菜单
 *
 * @param id
 * @param data
 */
export const updateMenu = (id: string, data: MenuForm) => request.put(Api.LISTMENUS + "/" + id, data);

/**
 * 删除菜单
 *
 * @param id 菜单ID
 */
export const deleteMenu = (id: number) => request.delete(Api.LISTMENUS + "/" + id);
